#include <iostream>
#include <algorithm>
#include <vector>
using namespace std;

int main()
{
    int n; cin >> n;
    vector<vector<int>> arr(n, vector<int>(2));
    for(auto& r : arr) for(auto& c : r) cin >> c;
    sort(arr.begin(), arr.end());
    int ans = 1;
    for(int i = 0, r = arr[0][1]; i < arr.size(); ++i)
    {
        if(arr[i][1] <= r) continue;
        if(arr[i][0] > r) ans++;
        r = arr[i][1];
    }
    cout << ans;
    return 0;
}